﻿using System;
using System.Windows;
using System.Windows.Controls;
using Microsoft.EnterpriseManagement.UI.WpfWizardFramework;
 

namespace ServiceManager.TFSIntegration
{
    /// <summary>
    /// Interaction logic for TFSAdminSettingsConfigurationPage.xaml
    /// </summary>
    public partial class TFSAdminSettingsConfigurationPage : WizardRegularPageBase
    {

        private TFSAdminWizardData _TFSAdminWizardData = null;

        public TFSAdminSettingsConfigurationPage(WizardData wizardData)
        {
            InitializeComponent();

            DataContext = wizardData;
            _TFSAdminWizardData = DataContext as TFSAdminWizardData;
        }

        private void TestConnection_Click(object sender, RoutedEventArgs e)
        {
            TFSService.CanConnect(txtTFSUrl.Text);
        }

        private void NoPortalChecked(object sender, RoutedEventArgs e)
        {
            if (NoPortal.IsChecked.HasValue && NoPortal.IsChecked.Value)
            {
                txtPortalIncidentUrl.Text = string.Empty;
                txtPortalIncidentUrl.IsReadOnly = true;
                NoPortalLabel.FontWeight = FontWeights.Light;
            }
            else if (NoPortal.IsChecked.HasValue && !NoPortal.IsChecked.Value)
            {
                txtPortalIncidentUrl.IsReadOnly = false;
                NoPortalLabel.FontWeight = FontWeights.Normal;
            }
        }

        private void NoSyncChecked(object sender, RoutedEventArgs e)
        {
            if (NoSync.IsChecked.HasValue && NoSync.IsChecked.Value)
            {
                txtFrequency.Text = "0";
                txtFrequency.IsReadOnly = true;
                NoSyncLabel.FontWeight = FontWeights.Light;
            }
            else if (NoSync.IsChecked.HasValue && !NoSync.IsChecked.Value)
            {
                txtFrequency.Text = "30";
                txtFrequency.IsReadOnly = false;
                NoSyncLabel.FontWeight = FontWeights.Normal;
            }
        }
    }
}
